package com.example.zluserservice.controller;

import com.example.zluserservice.client.OperationLogFeignClient;
import com.example.zluserservice.common.base.PageResponse;
import com.example.zluserservice.common.base.ResponseResult;
import com.example.zluserservice.dto.request.OperationLogReqDTO;
import com.example.zluserservice.dto.response.OperationLogResDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author zhenliu（孙凌岳）
 * @Description 用户服务 - 操作日志控制器（RPC调用）
 * @Date 2025/6/21 10:17
 * @Version 1.0
 */
@Slf4j
@Api(tags = " 用户服务 - 操作日志控制器（RPC调用）")
@RestController
@RequestMapping("/user/log")
public class OperationLogController {
    @Resource
    private OperationLogFeignClient operationLogFeignClient;

    @PostMapping("page/{pageNum}/{pageSize}")
    @ApiOperation("分页查询操作日志（内部 RPC）")
    public ResponseResult<PageResponse<OperationLogResDTO>> findOperationResDTOPage(
            @RequestBody OperationLogReqDTO operationLogReqDTO,
            @PathVariable("pageNum") int pageNum,
            @PathVariable("pageSize") int pageSize) {
        PageResponse<OperationLogResDTO> operationLogResDTOPageResponse = operationLogFeignClient.findOperationResDTOPage(operationLogReqDTO, pageNum, pageSize);
        return ResponseResult.success(operationLogResDTOPageResponse);
    }

    /**
     * 根据id删除日志
     * @param operId
     * @return
     */
    @DeleteMapping("/{operId}")
    @ApiOperation("根据 ID 删除操作日志（内部 RPC）")
    public ResponseResult remove(@PathVariable("operId") Long operId) {
        return ResponseResult.success(operationLogFeignClient.remove(operId));
    }
}
